<%@ page import="java.util.ArrayList" %>
<%@ page import="Dao.booksDAO" %>
<%@ page import="JavaBean.Book" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ page isELIgnored="false"%>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>书籍管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../assets/css/layui.css">
</head>
<%
    booksDAO dao = new booksDAO();
    ArrayList<Book> list = dao.getAllBooks();
    request.setAttribute("list",list);
%>
<body>


<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
    <legend>书籍管理</legend>
</fieldset>

<table class="layui-table" lay-size="lg">
    <colgroup>
        <col width="100">
        <col width="150">
        <col>
    </colgroup>
    <thead>
    <tr>
        <th>ID</th>
        <th>书名</th>
        <th>作者</th>
        <th>出版社</th>
        <th>ISBN</th>
        <th>价格</th>
        <th>出版日期</th>
        <th>简介</th>
        <th>编辑</th>
        <th>删除</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach var="book" items="${list}" varStatus="status">
        <tr>
            <td>${book.getId()}</td>
            <td>${book.getName()}</td>
            <td>${book.getAuthor()}</td>
            <td>${book.getIsbn()}</td>
            <td>${book.getPublish()} </td>
            <td>${book.getPrice()} </td>
            <td>${book.getPublishdate()} </td>
            <td>${book.getBookresume()} </td>

            <td>
                <a href='EditBook.jsp?id=${book.getId()}'><button type="button" class="layui-btn"><i class="layui-icon">修改</i></button></a>
            </td>
            <td>
                <a href='doDeleteBook.jsp?id=${book.getId()}' onclick="return confirm('确定删除吗？')"><button type="button" class="layui-btn layui-btn-danger"><i class="layui-icon"> 删除</i></button></a>
            </td>
        </tr>
    </c:forEach>
    </tbody>
</table>
<div style="text-align: center;">
    <a href="AddBook.jsp" style="position:fixed;bottom:6px"><button  type="button" class="layui-btn layui-btn-normal layui-btn-radius">新增</button></a>
</div>

<!-- <a href="../../index.jsp" style="position:fixed;bottom:6px;left: 80px"><button type="button" class="layui-btn layui-btn-primary layui-btn-radius">返回</button></a> -->
<script src="../assets/layui.all.js"></script>
</body>
</html>